import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
import { ApiParamsValidationPipe } from './common/pipes/api-params-validation.pipe';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { join } from 'path';
import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule,{
    cors: {
			origin: '*',
			credentials: true,
		},
  });
  //异常过滤器
  app.useGlobalFilters(new HttpExceptionFilter());
  //全局类验证器
  app.useGlobalPipes(new ApiParamsValidationPipe());
  const options = new DocumentBuilder()
		.setTitle('登录服务 API')
		.setDescription('登录服务接口文档')
		.setVersion('0.0.1')
		.build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api', app, document);
  app.useStaticAssets(join(__dirname, '../public/'),{
    prefix: ''
  })
  await app.listen(3020);
}
bootstrap();
